Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add language-specific note about TypeScript decorators. #1345

Merged
merged 2 commits into from
Jul 2, 2024

Conversation

justinfagnani
Copy link
Contributor

Adds a small note to the component overview that points users to the TypeScript decorator docs.

This is hopefully a small improvement on pointing new readers towards docs that will help them enable decorators correctly. Some users get errors when copying code to their TypeScript projects because they are not enabling experimental decorators and that's what our samples use.

We would ideally note that the TypeScript samples use experimental decorators, and even have a switch between standard and experimental decorators in samples, but that's more work to do and possibly a lot of complexity if not done right. This is a small incremental fix in one place instead.

This adds the ability to have language-specific content to the site by adding selectors that hide content that doesn't match the users preferred code language.

This will only show when the user's preference is TypeScript:

<div code-language="ts">...</div>

@justinfagnani justinfagnani requested review from rictic and e111077 July 2, 2024 00:15
Copy link

github-actions bot commented Jul 2, 2024

A live preview of this PR will be available at the URL(s) below.
The latest URL will be appended to this comment on each push.
Each build takes ~5-10 minutes, and will 404 until finished.

https://pr1345-1325f46---lit-dev-5ftespv5na-uc.a.run.app/
https://pr1345-6b916de---lit-dev-5ftespv5na-uc.a.run.app/

Copy link
Member

@augustjk augustjk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. I had the same thought after seeing the latest issue.
I suppose it might be overkill to add the same aside to the components/defining and components/properties section too.

@@ -80,3 +80,13 @@ a {
height: 1px;
overflow: hidden;
}

body[code-language-preference="ts"] [code-language]:not([code-language="ts"]) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I didn't see that. I had started making a new component before I looked into how switchable sample worked and figured that plain CSS was just easier.

@justinfagnani
Copy link
Contributor Author

I suppose it might be overkill to add the same aside to the components/defining and components/properties section too.

I do think there should be a more comprehensive solution, but maybe that looks like an info icon on the samples that triggers a popover with links?

@justinfagnani justinfagnani merged commit 9db43a0 into main Jul 2, 2024
15 checks passed
@justinfagnani justinfagnani deleted the typescript-note branch July 2, 2024 01:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants